import * as Types from "./mutations-types"
import {arrys} from "@/assets/random/random"
const mutations={
  [Types.ADD_PLATLIST](state,MySonInfo){
    //判断当前传入的歌曲是否已在播放列表、如果没有,就返回undefined
    let music=state.playList.find(item=>item.Singerinof.mid===MySonInfo.Singerinof.mid)
    if(music){
        //修改当前播放索引/播放当前点击（播放列表已有的歌曲）的歌曲
        state.currenIndex=state.playList.indexOf(music)
    }else{
      state.playList.push(MySonInfo)
      state.sequenceList.push(MySonInfo)
      //播放当前（新增）这首歌
      state.currenIndex=state.playList.length-1
    }
    //设置当前播放状态
    state.fullScreen=true;
    state.playing=true;
    // this.sequenceList=this.playList;
    console.log(MySonInfo)
  },
  //转换播放器
  [Types.UPDATE_FULLSCREEN](state){
    state.fullScreen=!state.fullScreen;
  },
  //修改播放状态
  [Types.UPDATE_PLAYING](state,bools){
    state.playing=bools;
  },
  //切换上、下歌曲
  [Types.UPDATE_CURRENTINDEX](state,index){
    state.currenIndex=index;
  },
  //点开改变播放模式
  [Types.UPDATE_CHANGEMODE](state){
    state.mode=(state.mode+1)%3;
  },
  //打乱播放列表。切换到随机播放
  [Types.UPDATE_PLALIST](state){
    state.playList=arrys(state.playList)
    state.playing=true
  },
  //切换到顺序播放发
  [Types.UPDATE_SEQUENCELIST](state){
    // JSON.parse(JSON.stringify(state.sequenceList))
    state.playList=JSON.parse(JSON.stringify(state.sequenceList))
    state.playing=true
    // console.log(state.playList)
  },
}
export default mutations;
